package com.zhuge_new.Adapter;

import android.content.Context;
import android.os.AsyncTask;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;

import com.bumptech.glide.Glide;
import com.zhuge_new.Activity.RedDisplayActivity;
import com.zhuge_new.R;
import com.zhuge_new.http.StringDialogCallback;
import com.zhuge_new.share.Const;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lenovo on 2018-09-14.
 */

public class RedDisponAdapter extends RecyclerView.Adapter<RedDisponAdapter.ViewHolder>{

    private ImageView iv_red;
    private Context context;
    private List<String> picturesList=new ArrayList<>();
    public RedDisponAdapter(RedDisplayActivity context, List<String> picturesList) {
        this.context=context;
        this.picturesList=picturesList;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view=View.inflate(context,R.layout.item_reddispon,null);
        ViewHolder viewHolder=new ViewHolder(view);
        return viewHolder;
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
       holder.iv_red.setImageDrawable(context.getDrawable(R.mipmap.ic_launcher));
       Glide.with(context).load(picturesList.get(position)).into(iv_red);
    }

    @Override
    public int getItemCount() {
        return picturesList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        private ImageView iv_red;

        public ViewHolder(View itemView) {
            super(itemView);
            iv_red = itemView.findViewById(R.id.iv_red);
        }
    }
}
